<template>
  <div class="A">
    <button @click="emitB">派发一个事件</button>
  </div>
</template>

<script setup lang="ts">
import { ref } from "vue"

// 常规写法 父传子
/* const emit = defineEmits(['on-click'])
let flag = ref(false)
const emitB = () => {
  flag = !flag  
  emit("on-click", flag)
} */

// bus 事件总线写法
import Bus from "../bus"

let flag = ref(false)
const emitB = () => {
  flag = !flag
  Bus.emit("on-click", flag)
}

</script>

<style>
.A {
  width: 200px;
  height: 200px;
  color: aquamarine;
  background-color: rgb(42, 131, 172);
}
</style>